home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / bbs / bnkfre11.zip / BANK.ZIP / BANK.PPS < prev    next >
Text File  |  1996-09-19  |  55KB  |  2,061 lines

  1. ;  BANK.PPE - Originally Written by JP Palazzolo
  2. ;             February 25, 1996
  3. ;             Additional work by Dan Shore
  4. ;
  5. ;  Purpose:  To allow a user to "Bank" time and bytes for use
  6. ;            on a future date.  Bank balances controlled by
  7. ;            entries in the configuration file.
  8. ;
  9. ; To install:
  10. ;
  11. ;    1) Edit your CMD.LST file(s) to add this:
  12. ;
  13. ;                             Charges Per     PPE/MNU File Specification -or-
  14. ;            Command    Sec  Minute    Use    Keystroke Substitution
  15. ;        ══════════════ ═══ ═════════════════ ═════════════════════════════════
  16. ;     1) BANK             5        0        0 C:\PCB\PPE\BANK\BANK.PPE
  17. ;
  18. ;       Note: You may have to change the pathname to the PPE.
  19. ;       Note: You may have to change the security level of the PPE.
  20. ;
  21. ;──────────────────────────────────────────────────────────────────────────────
  22. '
  23. '  Declare our variables
  24. '
  25. STRING dbfields(8)             ' Database fields
  26.  
  27. STRING gamble_mod(15)          ' Gambling modules
  28.  
  29. STRING hold                    ' Generic STRING variable
  30. STRING hold2                   ' Generic STRING variable
  31. STRING temp                    ' Generic STRING variable
  32. STRING main_prompt             ' Generic prompt for user input
  33. STRING user_input              ' Generic user input
  34. STRING bank_inf_file           ' BANK????.INF path and name
  35. STRING exchange_value          ' User input for exchange
  36.  
  37. STRING pcb_user_name           ' Username
  38. STRING key                     ' Variable to hold key hit
  39. STRING cfg_sl                  ' Security Level to match (CFG)
  40.  
  41. STRING last_date               ' Last date user used Bank
  42. STRING wd_byte_date            ' Last date of bytes w/d
  43. STRING wd_time_date            ' Last date of time w/d
  44. STRING max_dl_bytes            ' Password file D/L Byte Limit
  45.  
  46. INTEGER byte_wd                ' bytes withdrawn for day
  47. INTEGER max_byte_wd            ' Max bytes user can w/d per day (CFG)
  48. INTEGER bank_bytes             ' Current Bank Bytes
  49. INTEGER max_bank_bytes         ' Maximum bytes to deposit (CFG)
  50.  
  51. INTEGER time_wd                ' time withdrawn for day
  52. INTEGER max_time_wd            ' Max time user can w/d per day (CFG)
  53. INTEGER bank_time              ' Current Bank Time
  54. INTEGER max_bank_time          ' Maximum time allowed to deposit (CFG)
  55.  
  56. INTEGER time_exchange_rate     ' Exchange rate for giving time
  57. INTEGER byte_exchange_rate     ' Exchange rate for giving bytes
  58.  
  59. INTEGER size                   ' Generic INTEGER variable
  60.  
  61. INT x                          ' Generic INT variable
  62. INT trans_type                 ' Used for withdraw/deposit error type
  63.                                '  Also used in exchange for bank/online type
  64. DATE inf_date                  ' Date of BANK????.INF file
  65.  
  66. TIME inf_time                  ' Time of BANK????.INF file
  67.  
  68. BOOLEAN do_withdraw            ' Flag for withdraw (not deposit)
  69. BOOLEAN clear_21               ' Flag to clear line 21
  70. BOOLEAN do_time                ' Time or Byte action
  71. BOOLEAN use_bank_bal           ' Flag to use Bank Balance for exchange
  72. BOOLEAN use_online_bal         ' Flag to use online balance for exchange
  73. BOOLEAN ck_ok                  ' Flag for if user can exchange
  74. '──────────────────────────────────────────────────────────────────────────
  75. '
  76. '  Declare our procedures
  77. '
  78. DECLARE PROCEDURE WITHDRAW (BOOLEAN time)
  79. DECLARE PROCEDURE DEPOSIT (BOOLEAN time)
  80. DECLARE PROCEDURE WAIT_FOR_KEY ()
  81. DECLARE PROCEDURE CLEAR_20_21 (BOOLEAN clear_21)
  82. DECLARE PROCEDURE ADD_COMMAS (VAR STRING hold2)
  83. DECLARE PROCEDURE ASK_MAXIMUM (VAR INTEGER int1, INTEGER int2, INTEGER int3, INTEGER int4, INTEGER int5, VAR STRING user_input, VAR STRING hold, INT trans_type)
  84. DECLARE PROCEDURE CHECK_MAX (VAR BOOLEAN ck_ok)
  85. DECLARE FUNCTION GET_CONFIRM () BOOLEAN
  86.  
  87. *$USEFUNCS
  88.  
  89. BEGIN
  90.    '
  91.    '  Get info on current user
  92.    '
  93.    GETUSER
  94.  
  95.    '
  96.    '  Open node specific Log file
  97.    '
  98.    FAPPEND 7, PPEPATH() + "NODE" + STRING(PCBNODE()) + ".LOG", O_RW, S_DN
  99.    FPUTLN 7, "────────────── " + MIXED(U_NAME()) + " ──────────────"
  100.  
  101.    '
  102.    '  Open database and index
  103.    '
  104.    GOSUB OPEN_DATABASE
  105.    GOSUB OPEN_INDEX
  106.    '
  107.    '  Find user in database, or add as a new user
  108.    '
  109.    GOSUB FIND_ADD_USER
  110.    '
  111.    '  Read the PASSWORDS file to get users maximum d/l byte limit
  112.    '
  113.    GOSUB GET_MAX_DL_BYTES
  114.    '
  115.    '  Clear the screen, read the configuration file
  116.    '
  117.    CLS
  118.    GOSUB READ_CONFIG
  119.    '
  120.    '  Determine our .INF file name and location
  121.    '
  122.    bank_inf_file = PPEPATH() + "BANK" + STRING(PCBNODE()) + ".INF"
  123.    '
  124.    '  If ANSI, display ANSI MENU
  125.    '
  126.    IF (ANSION()) GOSUB DISPLAY_MENU
  127.  
  128.    '
  129.    '  Log user information
  130.    '
  131.    GOSUB GET_INFO
  132.    FPUTLN 7, "              Date : ", DATE()
  133.    FPUTLN 7, "              Time : ", TIME()
  134.    FPUTLN 7, "Last Time W/D Date : ", wd_time_date
  135.    FPUTLN 7, "Last Byte W/D Date : ", wd_byte_date
  136.  
  137.    '
  138.    '  Prompt the user for their action
  139.    '
  140.    GOSUB MENU
  141.  
  142.    '
  143.    '  Exit the program
  144.    '
  145.    GOTO EXIT_PROG
  146.  
  147. END
  148.  
  149.  
  150. '────────────────────────────────────────────────────
  151. '                Start of Subroutines
  152. '────────────────────────────────────────────────────
  153.  
  154. '
  155. '  Retrieve info from database and post to log
  156. '
  157. :GET_INFO
  158.    '
  159.    '  Get database info
  160.    '
  161.    bank_time = DGET (7,"banktime")
  162.    bank_bytes = DGET (7,"bankbytes")
  163.    last_date = DGET (7,"last_d_acc")
  164.    wd_byte_date = DGET (7, "bytewddate")
  165.    wd_time_date = DGET (7, "timewddate")
  166.    byte_wd = DGET (7, "bytewd")
  167.    time_wd = DGET (7, "timewd")
  168.    '
  169.    '  If wd date is not todays date, zero out variables
  170.    '
  171.    IF (wd_byte_date != STRING(DATE())) byte_wd = 0
  172.    IF (wd_time_date != STRING(DATE())) time_wd = 0
  173.  
  174.    RETURN
  175.  
  176. '
  177. '  Display maximum bank amounts available to the user
  178. '
  179. :DISPLAY_MAX_BANK_AMOUNTS
  180.    '
  181.    '  ANSI Display
  182.    '
  183.    IF (ANSION()) THEN
  184.      '
  185.      '  Display Bank Time Information
  186.      '
  187.      IF (max_bank_time != 0) THEN
  188.        '
  189.        ' Display maximum time balance and max time w/d per day
  190.        '
  191.        ANSIPOS 21,11
  192.        PRINT "@X02", max_bank_time
  193.        ANSIPOS 21, 12
  194.        PRINT "@X02", max_time_wd
  195.      ELSE
  196.        ANSIPOS 21,11
  197.        PRINT "@X03Insuff. Security"
  198.        ANSIPOS 21, 12
  199.        PRINT "@X03Insuff. Security"
  200.      END IF
  201.      '
  202.      '  Display Bank Byte Information
  203.      '
  204.      IF (max_bank_bytes != 0) THEN
  205.        '
  206.        ' Display maximum byte balance
  207.        '
  208.        ANSIPOS 60, 11
  209.        size = max_bank_bytes
  210.        ADD_COMMAS (hold2)
  211.        PRINT "@X02", hold2
  212.        '
  213.        '  Display maximum byte withdraw/day amount
  214.        '
  215.        ANSIPOS 60, 12
  216.        size = max_byte_wd
  217.        ADD_COMMAS (hold2)
  218.        PRINT "@X02", hold2
  219.      ELSE
  220.        ANSIPOS 60, 11
  221.        PRINT "@X03Insuff. Security"
  222.        ANSIPOS 60, 12
  223.        PRINT "@X03Insuff. Security"
  224.      END IF
  225.    ELSE
  226.      '
  227.      '  Non-Ansi display
  228.      '
  229.      PRINTLN "     Maximum Bank Time Allowed: ", max_bank_time
  230.      PRINTLN " Maximum Time Withdraw Per Day: ", max_time_wd
  231.      '
  232.      IF (max_bank_bytes != 0) THEN
  233.        PRINTLN "    Maximum Bank Bytes Allowed: ", max_bank_bytes
  234.        PRINTLN "Maximum Bytes Withdraw Per Day: ", max_byte_wd
  235.      ELSE
  236.        PRINTLN "    Maximum Bank Bytes Allowed: Insuff. Security"
  237.        PRINTLN "Maximum Bytes Withdraw Per Day: Insuff. Security"
  238.      END IF
  239.      '
  240.    END IF
  241.  
  242.    RETURN
  243.  
  244. '
  245. '  Find out maximum download bytes available for user
  246. '
  247. :GET_MAX_DL_BYTES
  248.    '
  249.    '  Find password file in PCBOARD.DAT and find matching
  250.    '  security level.  Once found, get the total d/l bytes
  251.    '  available to the user.
  252.    '
  253.    '  Security level is the 2nd parameter and daily d/l byte limit
  254.    '  is the 4th parameter.
  255.    '
  256.    '
  257.    hold = RTRIM(READLINE(PCBDAT(),32)," ")
  258.    FOPEN 1, hold, O_RD, S_DN
  259.    WHILE (1) DO
  260.      '
  261.      '  Read a line from the passwrd file
  262.      '
  263.      FGET 1, hold2
  264.      '
  265.      '  Check for EOF
  266.      '
  267.      IF (FERR(1)) BREAK
  268.      '
  269.      '  Replace any commas with semi-colons so we can tokenize string
  270.      '
  271.      hold2